export interface IBaseRequest<T> {
  code: number;
  data: T;
  msg: string | null;
}

export type IPageRequest<T> = IBaseRequest<{
  total_pages: number;
  total_record: number;
  current_data: T[];
}>;

export type Role = 'ADMIN' | 'COMMON';

export interface ISearchParams {
  page: number;
  size: number;
  gmt_end?: string;
  gmt_start?: string;
  condition?: string | number;

  total: number;
}

export interface IBase {
  id: number;
  del: number;
  gmt_create: string;
  gmt_modified: string;
}

export interface IUser extends IBase {
  username: string;
  head_img: string;
  phone: string;
  pwd: string;
  slogan: string;
  sex: number;
  city: string;
  position: string;
  learn_time: string;
  role: Role;
}

export interface IRole {
  name: string;
  color: string;
  realName: Role;
}

export interface IProduct extends IBase {
  title: string;
  cover_img: string;
  old_amount: string;
  amount: string;
  summary: string;
  detail: string;
  product_type: string;
  uv: number;
  buy_num: number;
  teacher_id: number;
  course_level: string;
  hour: number;
  episode_num: number;
  player: string;
  tdk: string;
  bd_zip_url: string;
  note_url: string;
  total_point: string;
  content_point: string;
  easy_point: string;
  logic_point: string;
}

export interface IOrder extends IBase {
  ip: string;
  username: string;
  account_id: number;
  product_id: number;
  out_trade_no: string;
  order_state: string;
  total_amount: string;
  pay_amount: string;
  product_type: string;
  product_title: string;
  product_img: string;
  user_head_img: string;
}

export interface IChapter extends IBase {
  title: string;
  ordered: number;
  productId: number;
  episodeList: IEpisode[];
}

export interface IEpisode extends IBase {
  title: string;
  ordered: number;
  hwyun_id: string;
  chapterId: number;
  duration: string;
  productId: number;
}

export interface IAddProduct {
  title: string;
  hour: string;
  detail: string;
  teacher_id: string;
  summary: string;
  note_url: string;
  bd_zip_url: string;
  amount: number | undefined;
  old_amount: number | undefined;
}

export type Episode = Omit<
  IEpisode,
  keyof IBase | 'productId' | 'hwyun_id' | 'duration'
>;
export type Chapter = Omit<
  IChapter,
  keyof IBase | 'productId' | 'episodeList'
> & { episodeList: Episode[] };
